﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.ContentManagement.Handlers;
using Orchard.Environment.Extensions;
using Orchard.Events;
using Orchard.ContentManagement;

namespace Downplay.Audit.Handlers
{
    public interface IRulesManager : IEventHandler
    {
        void TriggerEvent(string category, string type, Func<Dictionary<string, object>> tokensContext);
    }

    [OrchardFeature("Downplay.Audit.Rules.Content")]
    public class AuditHandler : ContentHandler
    {

        public AuditHandler(IRulesManager rulesManager)
        {
            // Trigger rules event on display
            OnGetDisplayShape<ContentPart>(
                (context, part) =>
                    rulesManager.TriggerEvent("Content", "Displayed",
                    () => new Dictionary<string, object> { { "Content", context.ContentItem },{"DisplayType", context.DisplayType } }));
        }

    }
}
